package com.ohuang.demo.storage

import android.content.Context
import kotlin.reflect.KProperty

operator fun <T> IStorage<T>.getValue(thisObj: Any?, property: KProperty<*>): T = getValue()
operator fun <T> IStorage<T>.setValue(thisObj: Any?, property: KProperty<*>, value: T) {
    setValue(value)
}

operator fun <T> IStorage2<T>.getValue(thisObj: Any?, property: KProperty<*>): T {
    return getValue(property.name)
}

operator fun <T> IStorage2<T>.setValue(thisObj: Any?, property: KProperty<*>, value: T) {
    setValue(property.name, value)
}

fun <T> Context.getSpStorage(spName: String, key:String,default: T): IStorage<T> {
    return SpStorageUtil(this.applicationContext, spName).get(key, default)
}

fun <T> Context.getSpStorage(spName: String, default: T): IStorage2<T> {
    return SpStorageUtil(this.applicationContext,spName).get(default)
}


